import {Message} from '../../models/message' 
import  {Chatcontroller} from '../../models/3.0/chatcontroller'
let getchatcontroller =  new Chatcontroller()
let givMessage= new Message()
Page({
  /**
   * Page initial data
   */
  data: {
    active: 0 ,
    list:[],
    html:'',
    chatlist:[],
    userlist:[]

  },
 
  // 点赞 收藏 粉丝 评论的数量
  number(){
    givMessage.number(res=>{
      console.log(res);
      this.setData({
        list:res
      })
    console.log(this.data.list[0]  ); 
  })
  },
  tochatroom(){
    wx.navigateTo({
        url: '../../packageA/pages/chat-room/chat-room?toUser=123456&toUserId=123456'
    })
  },
  tocschatroom(){
    wx.navigateTo({
        url: '../../packageA/pages/cs-chat-room/cs-chat-room?toUser=123456&toUserId=123456'
    })
  },
  getchat(){
  getchatcontroller.getTalking().then(res=>{
    console.log(res)
    this.setData({
      'userlist':res
    })
  })
},
 getchatcontroller(){
   
  grtchatcontroller.getTalking().then(res=>{
    this.setData({
      'chatlist':res
    })
    console.log("聊天列表",this.data.chatlist)
  })

 },


  /**
   * Lifecycle function--Called when page load
   */

 
 onLoad: function (options) {

 },

  /**
   * Lifecycle function--Called when page is initially rendered
   */
  onReady: function () {},

  /**
   * Lifecycle function--Called when page show
   */
  onShow: function () {
    this.getTabBar().init()
    this.number()
    this.getchat()

  },

  /**
   * Lifecycle function--Called when page hide
   */
  onHide: function () {},

  /**
   * Lifecycle function--Called when page unload
   */
  onUnload: function () {},

  /**
   * Page event handler function--Called when user drop down
   */
  onPullDownRefresh: function () {},

  /**
   * Called when page reach bottom
   */
  onReachBottom: function () {},

  /**
   * Called when user click on the top right corner to share
   */
  onShareAppMessage: function () {}
})
